<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<% request.setAttribute("ctx", request.getContextPath()); %>
<html>
<head>
    <link href="${ctx}/favicon.ico" type="image/x-icon" rel="shortcut icon">
    <title>文档列表</title>
    <script type="text/javascript" src="${ctx}/js/jquery.min.js"></script>
    <script type="text/javascript" src="${ctx}/js/uploadify/jquery.uploadify.min.js"></script>
    <link rel="stylesheet" type="text/css" href="${ctx}/js/uploadify/uploadify.css">
    <link rel="stylesheet" type="text/css" href="${ctx}/css/table.css">
    <style type="text/css">
        body {
            font: 13px Arial, Helvetica, Sans-serif;
        }
    </style>
</head>
<body>
<table class="list">
    <thead>
    <tr>
        <th>名称</th>
        <th colspan="2">操作</th>
        <th>总页数</th>
        <%--<th>大小</th>--%>
        <th>类型</th>
        <th>状态</th>
        <th>创建时间</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach var="doc" items="${docs}">
        <tr>
            <td>${doc.name}</td>
            <c:set var="dst" value="${doc.status}" />
            <td><c:if test="${dst == 'SUCCESS'}"><a href="view?did=${doc.id}" target="_blank">预览</a></c:if></td>
            <td><a href="dl?did=${doc.id}">Download</a></td>
            <td>${doc.totalPages}</td>
                <%--<td>${doc.size / 1024}K</td>--%>
            <td>${doc.type}</td>
            <td>${dst == 'WAIT' ? "等待" : dst == 'RUNNING' ? "转换中" : dst == 'SUCCESS' ? "可查看" : "失败"}</td>
            <td></td>
        </tr>
    </c:forEach>
    </tbody>
</table>
</fieldset>
<form>
    <input id="fileUpload" name="multipart" type="file" multiple="true">
    <a href="javascript:$('#fileUpload').uploadify('upload','*')">Upload Files</a>

    <div id="queue"></div>
</form>
<script type="text/javascript">
    $(function () {
        $('#fileUpload').uploadify({
            'formData': {
                //'timestamp' : '<?php echo $timestamp;?>',
                //'token'     : '<?php echo md5('unique_salt' . $timestamp);?>'
            },
            'auto': false,
            'swf': '${ctx}/js/uploadify/uploadify.swf',
            'uploader': 'ul',
            'fileObjName': 'multipart',
            'fileTypeDesc': 'Document Files',        // The description for file types in the browse dialog
            // 'fileTypeExts': '*.pdf;*.doc;*.docx;*.xls;*.xlsx;*.ppt;*.pptx;*.txt;*.xml;*.png;*.jpg;',
            'fileTypeExts': '*.pdf;*.doc;*.docx;*.xls;*.xlsx;*.ppt;*.pptx;*.txt;*.png;*.jpg;',
            'onQueueComplete': function (queueData) {
                //alert(queueData.uploadsSuccessful + ' files were successfully uploaded.');
                location.reload();
            }
            /*
             'onUploadSuccess': function (file, data, response) {
             //alert('The file ' + file.name + ' was successfully uploaded with decode response of ' + response + ':' + data);
             location.reload();
             }
             */
        });
    });
</script>
<hr/>
</body>
</html>
